package com.hundsun.network.eclp.ex.common;

import java.util.HashMap;
import java.util.Map;

/**
 * 后台权限枚举
 * <pre>
 *  （一）子系统权限code由330000开始,
 *  	  数字选择要分清层次。
 *  （二）枚举名称name定义遵循下面规则：
 *          格式：XXX_Y_ZZZ
 *          				XXX是业务相关的模块缩写，
 *          				Y是CRUD字母之一（代表增查改删动作），
 *          				ZZZ是操作对应的英文缩写。
 *          ---------------------------------------------------
 *          例：BASE_C_TYPEADD(14101,"项目类型添加")
 *          “BASE”是指“系统基础设置”模块，
 *          “C”是指“添加”属于Create动作，
 *          “TYPEADD”是指“typeAdd”这个操作，
 *          “14101”是该权限的code，
 *          “项目类型添加”是该权限的desc。
 *          ---------------------------------------------------
 *   （三）权限code和ECLP中配置保持一致。
 * </pre>
 */
public enum PermissionEnum {
	/**
	 * 由于目前权限代码从330000，可分配为4位数，故按如下规则分配
	 * 一级菜单[顶级模块]按400号段分 ， 如 330400 、330800
	 * 二级菜单[子模块]按20号段分，如 330420、330440
	 * 三级菜单即操作则以间隔1区分，如 330421、330422
	 */
		
	/**
	 * 商品管理模块
	 */
	GOODS_MANAGE(330000,"商品管理"),
	

	/**
	 * 专场管理模块
	 */
	PLATE_MANAGE(330400,"专场管理"),

	PLATE_MANAGE_ADD(330420,"专场新增"),

	PLATE_MANAGE_DEFEND(330440,"专场维护"),
	PLATE_MANAGE_DEFEND_UPDATE(330441,"专场修改"),
	PLATE_MANAGE_DEFEND_DELETE(330442,"专场删除"),
	PLATE_MANAGE_DEFEND_VIEW(330443,"专场查看"),

	/**
	 * 分类管理模块
	 */
	CLASSIFY_MANAGE(330800,"分类管理"),
	
	CLASSIFY_MANAGE_DEFEND(330820,"分类维护"),
	CLASSIFY_MANAGE_DEFEND_ADD(330821,"分类新增"),
	CLASSIFY_MANAGE_DEFEND_UPDATE(330822,"分类修改"),
	CLASSIFY_MANAGE_DEFEND_DELETE(330823,"分类删除"),
	CLASSIFY_MANAGE_DEFEND_ENABLE(330824,"分类启用"),
	CLASSIFY_MANAGE_DEFEND_DISABLE(330825,"分类禁用"),

	/**
	 * 系统参数配置模块
	 *
	 * */
	SYSTEM_PARAMTER_MANAGE(331200,"系统管理"),
	SYSTEM_BUSSINISE_PARAMTER(331220,"业务参数配置"),
	SYSTEM_BUSSINISE_PARAMTER_EDIT(331221,"业务参数配置修改"),
	
	
	/**
	 * 交易账户模块
	 */
	ACCOUNT_MANAGE(331600,"账户管理"),
	ACCOUNT_MANAGE_LIST(331620,"账户列表"),
	ACCOUNT_QUOTA_LIST(331640,"配额变动流水"),
	
	ENTRUST_MANAGE(332000,"委售管理"),
	ENTRUST_MANAGE_LIST(332020,"委售单列表"),
	ENTRUST_MANAGE_AUDIT_LIST(332040,"撤回记录"),
	ENTRUST_MANAGE_ROLLBACK_LIST(332060,"撤回记录"),
	
	ORDER_MANAGE(332400,"订单管理"),
	ORDER_MANAGE_LIST(332420,"全部订单"),
	ORDER_WAIT_DELIVERY_LIST(332440,"待发货订单"),
	ORDER_COMPELE_DELIVERY_LIST(332460,"已发货订单"),
	ORDER_WAIT_RECEVIE_LIST(332480,"待收货订单"),
	ORDER_COMPLETE_LIST(332500,"已完成订单"),
	ORDER_ENTRUST_LIST(332520,"已挂售订单"),

	/**
	 * 报表管理模块
	 */
	REPORT_MANAGE(332800,"报表管理"),
	REPORT_ORDER_RETAILAREA_LIST(332820,"零售商品每日成交"),
	REPORT_ORDER_WHOLESALEAREA_LIST(332840,"批发商品每日成交"),
	REPORT_ORDER_CLINCH(332860,"成交明细报表"),
	REPORT_ACCOUNT_QUOTA_DAILY(332880,"配额每日统计报表"),
	
	;
	 private static Map<Object, PermissionEnum>        pool        = new HashMap<Object, PermissionEnum>();

	    static {
	        for (PermissionEnum each : PermissionEnum.values()) {
	            PermissionEnum defined = pool.get(each.code);
	            if (null != defined) {
	                throw new java.lang.IllegalArgumentException(defined.toString()
	                                                             + " defined as same code with "
	                                                             + each.toString());
	            }
	            pool.put(each.code, each);
	            pool.put(each.name(), each);
	        }
	    }

	PermissionEnum(int code, String desc){
		  this.code = code;
	      this.desc = desc;
	}

    private int code;

    private String desc;

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static PermissionEnum indexOf(int code) {
        return pool.get(code);
    }

    public static PermissionEnum indexOf(String name) {
        return pool.get(name);
    }

    public static Map<Integer, String> toMap() {
        Map<Integer, String> map = new HashMap<Integer, String>();
        for (PermissionEnum record : values()) {
            map.put(record.getCode(), record.getDesc());
        }
        return map;
    }
}
